home *** CD-ROM | disk | FTP | other *** search
- Path: crl.crl.com!not-for-mail
- From: bobfry@crl.com (Robert Fry)
- Newsgroups: comp.unix.sco.programmer,comp.lang.c
- Subject: Re: Storing 20 character numbers
- Date: 3 Apr 1996 16:42:54 -0800
- Organization: CRL Dialup Internet Access
- Message-ID: <4jv5ue$6c8@crl.crl.com>
- References: <DpB3sz.J9n@idm.com>
- NNTP-Posting-Host: crl.com
-
- eck@idm.com (Eric Kurbat) writes:
-
- > Anyway, the question is, how do you store a 20 character integer
- >number in a non-character variable in C without losing any of the digits?
- >I did a little bit of playing around and a long double loses precision after
- >about 16 digits. Does anyone have any ideas?
-
- Gee, it works on my system when I just store it as a long! Seriously, the
- exact maximum precision on any system is implementation defined. If you
- want to store numbers with higher precision than that, you will need to
- create your own data types to do the job. One fairly common (though far
- from the most space-efficient) implementation is to store one or two
- digits per byte, and do the carries, etc, whenever you do operations on
- the numbers. This can be a lot of work if you need to implement efficient
- math routines for various operations, but it's the only portable solution
- I can think of.
-
- Bob
-